from .models import Usertable

class loginService():

    def sumbit(req):
        user = req['user']
        password = req['password']
        t = Usertable.objects.filter(username = user)
        data = {}
        if t:
            for i in t:
                if i.userkey == password:
                    data = {'code': 900, 'msg': '登录成功'}
                else:
                    data = {'code': 902, 'msg': '密码错误'}
        else:
            data = {'code': 901, 'msg': '用户名错误'}

        return data